package com.hongsheng.service.impl;

/*
@Author：郭振文
@Package：com.hongsheng.service.impl
@File：AuthorityServiceImpl
@Date：2023/8/11 11:36
*/

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hongsheng.mapper.AuthorityMapper;
import com.hongsheng.pojo.Authority;
import com.hongsheng.service.AuthorityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class AuthorityServiceImpl implements AuthorityService {

    @Autowired
    private AuthorityMapper authorityMapper;

    @Override
    public Boolean insertAuthority(Authority authority) {
        int i = authorityMapper.insert(authority);
        return i>0;
    }

    @Override
    public Boolean deleteAuthority(Integer id) {
        int i = authorityMapper.deleteById(id);
        return i>0;
    }

    @Override
    public Boolean updateAuthority(Authority authority) {
        int i = authorityMapper.updateById(authority);
        return i>0;
    }

    @Override
    public PageInfo<Authority> selectAuthority(Integer currentPage, Integer pageSize, Authority authority) {
        PageHelper.startPage(currentPage,pageSize);
        List<Authority> authorityList = authorityMapper.selectAuthority("%"+authority.getAuthorityName()+"%","%"+authority.getFeatures()+"%");
        return new PageInfo<Authority>(authorityList);
    }

    @Override
    public List<Authority> selectAuthority1() {
        List<Authority> authorityList = authorityMapper.selectAuthority1();
        return authorityList;
    }

    @Override
    public Authority selectAuthorityById(Integer id) {
        Authority authority = authorityMapper.selectById(id);
        return authority;
    }

}
